/*
 * MandelbrotQuadTreeCompute.h
 *
 *  Created on: 15.07.2012
 *      Author: 116
 */

#ifndef MANDELBROTQUADTREECOMPUTE_H_
#define MANDELBROTQUADTREECOMPUTE_H_

/**
 * computes the next node for the given root node.
 *
 * May not compute anything if the maxDepth criteria can't be satisfied
 *
 * The user must provide 2 arrays of doubles, allocated.
 * The first one must be 8*pointsPerSide long.
 * The second one must be 2*pointsPerSide*pointsPerSide long.
 *
 * return the depth reached so far otherwise if a node was computed
 * -1 if no node was computed
 */
int computeNextNode(MandelbrotQuadTree * root, double * edgeArray, double * innerArray, unsigned int pointsPerSide, unsigned int maxComputationDepth,
        unsigned int maxIter, unsigned int diffIterLimit);

MandelbrotQuadTree * nextNodeToCompute(MandelbrotQuadTree * sourceNode, unsigned int maxComputationDepth);

/**
 * fills an array of doubles : [x1,y1,x2,y2,x3,y3,...]
 *
 * size of the array = 8 * pointsPerSide
 *
 * array must be allocated
 *
 */
void borderPointsAsFloat(MandelbrotQuadTree * node, double * destArray, unsigned int pointsPerSide);

/**
 * computes mandelbrot formula for this list of pint given in array
 *
 * array must be like [x1,y1,x2,y2,x3,y3,...]
 *
 * pointsCount is the number of points to compute, so it is also half the number of elements in the array
 *
 * maxIter is the maximum number of iterations to do before stopping the computation
 *
 * stops as soon as possible, returns 1 if all the points are inside the mandelbrot set, 0 otherwise
 *
 */
int isInsideMandelbrotSet(double * array, unsigned int pointsCount, unsigned int maxIter);

/**
 * fills an array of doubles : [x1,y1,x2,y2,x3,y3,...]
 *
 * size of the array = pointsPerSide * pointsPerSide * 2
 *
 * array must be allocated
 *
 */
void innerPointsAsDouble(MandelbrotQuadTree * node, double * array, unsigned int pointsPerSide);

#endif /* MANDELBROTQUADTREECOMPUTE_H_ */
